# -*- coding: utf-8 -*-


def test_python3_mysql():
    import pymysql
    conn = pymysql.connect(
        host="127.0.0.1",
        port=3306,
        user="root",
        passwd="chench",
        db="test"
    )

    cursor = conn.cursor()
    cursor.execute("SELECT VERSION();")
    version = cursor.fetchone()
    print("MySQL version:%s " % version)


def test():
    """
    pip install mysqlclient
    MySQLdb
    """
    import MySQLdb
    conn = MySQLdb.connect(host="127.0.0.1", port=3306, db="test", user="root", password="chench", connect_timeout=10)
    cursor = conn.cursor()
    cursor.execute("SELECT VERSION();")
    version = cursor.fetchone()
    print("MySQL version:%s " % version)
    conn.close()


if __name__ == '__main__':
    test_python3_mysql()

    # test()

    pass
